import { PORT3 } from "@/api/config/servicePort";
import http from "@/api";
import { WorkerSmash } from "../interface/workerSmash";
import { defaultParams } from "@/interface/public";
import { WorkerSo } from "../interface/workerSo";

interface itemProps {
  id: string;
  itemIds: string;
}

// 1-保存工单
export const workerSmashSave = (params: WorkerSmash.Save) => http.post(PORT3 + `/workerSmash/save`, params);

// 2-查询工单列表
export const workerSmashPage = (params: WorkerSmash.SearchParams) =>
  http.post<WorkerSmash.Search>(PORT3 + `/workerSmash/page`, params);

// 2.1-查询工单明细
export const workerSmashItem = (params: defaultParams) => http.get(PORT3 + `/workerSmash/item/${params.id}`);

// 3-为工单追加明细
export const workerSmashAppendMaterial = (params: itemProps) => http.post(PORT3 + `/workerSmash/appendMaterial`, params);

// 4-查询待撕碎仓中待关联的清单
export const workerSmashWaitAppendRiveItem = (params: defaultParams) =>
  http.get<WorkerSo.WaitAppendItem>(PORT3 + `/workerSmash/waitAppendRiveItem/${params.id}`);

// 4.1-查询待粉碎仓中待关联的清单
export const workerSmashWaitAppendSmashItem = (params: defaultParams) =>
  http.get<WorkerSo.WaitAppendItem>(PORT3 + `/workerSmash/waitAppendSmashItem/${params.id}`);

// 5-为工单删除明细
export const workerSmashRemoveMaterial = (params: itemProps) => http.post(PORT3 + `/workerSmash/removeMaterial`, params);

// 6-删除工单
export const workerSmashRemove = (params: defaultParams) => http.post(PORT3 + `/workerSmash/remove/${params.id}`);

// 7-查询待开始工单
export const workerSmashListByWaitStart = () => http.get<WorkerSo.SearchProps[]>(PORT3 + `/workerSmash/listByWaitStart`);

// 7.1-开始工单
export const workerSmashStart = (params: defaultParams) => http.post(PORT3 + `/workerSmash/start/${params.id}`);

// 8-查询待结束工单
export const workerSmashListByWaitEnd = () => http.get<WorkerSo.SearchProps[]>(PORT3 + `/workerSmash/listByWaitEnd`);

// 8.1-结束工单
export const workerSmashEnd = (params: defaultParams) => http.post(PORT3 + `/workerSmash/end/${params.id}`);

// 9-查询待发送物料的工单
export const workerSmashListByWaitSend = () => http.get<WorkerSo.SearchProps[]>(PORT3 + `/workerSmash/listByWaitSend`);

// 9.1-查询工单下待发送物料明细
export const workerSmashWaitSendByWorker = (params: defaultParams) =>
  http.get<WorkerSo.SearchDetail[]>(PORT3 + `/workerSmash/waitSendByWorker/${params.id}`);

// 9.2-工单发料
export const workerSmashSendMaterial = (params: itemProps) => http.post(PORT3 + `/workerSmash/sendMaterial`, params);

// 9.3-工单发料退回
export const workerSmashBackSendMaterial = (params: itemProps) => http.post(PORT3 + `/workerSmash/backSendMaterial`, params);

// 10-查询待接收物料的工单
export const workerSmashListByWaitAccept = () => http.get<WorkerSo.SearchProps[]>(PORT3 + `/workerSmash/listByWaitAccept`);

// 10.1-查询工单下待接收物料明细
export const workerSmashWaitAcceptByWorker = (params: defaultParams) =>
  http.get<WorkerSo.SearchDetail[]>(PORT3 + `/workerSmash/waitAcceptByWorker/${params.id}`);

// 10.2-工单收料
export const workerSmashAcceptMaterial = (params: itemProps) => http.post(PORT3 + `/workerSmash/acceptMaterial`, params);

// 11-查询工单下待撕碎投入明细
export const workerSmashWaitRiveInByWorker = (params: defaultParams) =>
  http.get<WorkerSo.SearchDetail[]>(PORT3 + `/workerSmash/waitRiveInByWorker/${params.id}`);

// 12-查询待发送入库的工单
export const workerSmashListByWaitSendWarehouse = () =>
  http.get<WorkerSo.SearchDetail[]>(PORT3 + `/workerSmash/listByWaitSendWarehouse`);

// 13-查询待入库接收的工单
export const workerSmashListByWaitAcceptWarehouse = () =>
  http.get<WorkerSo.SearchDetail[]>(PORT3 + `/workerSmash/listByWaitAcceptWarehouse`);
